<?php
/*
 * [JINYUN!] (C)2001-2099 Jinyunweb.com
 * This is NOT a freeware, use is subject to license terms
 * $Id: 2017-12-13 03:39:35 apple $
*/
require_once './core/core.php';
if($_SERVER['HTTP_HOST']==DOMAIN){
	//如果当前域名为系统主域名，自动转向到系统后台
	if($_AR['system']['istakeover'] && $_AR['system']['takeoverplugin']){
		header('Location: ./custom/index.php');exit;
	}else{
		header('Location: ./manage/index.php');exit;	
	}
	
}
$check=pdo_getcolumn('core_accounts',array('domain'=>trim($_SERVER['HTTP_HOST'])),'uniacid');
if($check){
	$url=HTTP.$_SERVER['HTTP_HOST'].WEB_ROOT.'custom/index.php?i='.$check.'&plugin=core&action=home.welcome';
	header('location:'.$url);
	exit;
}
$query=pdo_getcolumn('core_domain',array('domain'=>$_SERVER['HTTP_HOST']),'url');
if($query){
	$query=explode('?',$query,2);
	$query=$query['1'];
	$url=HTTP.$_SERVER['HTTP_HOST'].'/custom/index.php?'.$query;
	header('location:'.$url);
	exit;
}
if(USER_DOMAIN && strexists($_SERVER['HTTP_HOST'],USER_DOMAIN)){
	//启用给用户分配独立域名，检查域名是否为系统分配的独立域名
	$uniacid=str_replace(USER_DOMAIN,'',$_SERVER['HTTP_HOST']);
	$uniacid=intval($uniacid);
	if($uniacid){
		//成功获得站点ID，存入$_RQ中备用
		$_RQ['i']=$uniacid;
		require 'custom/index.php';
	}else{
		exit;
	}
}
//没有开启分配独立域名功能或者给域名绑定URL，此处跳转管理端首页
if($_AR['system']['istakeover'] && $_AR['system']['takeoverplugin']){
	header('Location: ./custom/index.php');exit;
}else{
	header('Location: ./manage/index.php');
}
?>
